﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports System.Linq
Imports System.Collections.Generic
Imports <xmlns="http://kadgen.com/tempCode">


Public Class ImportInfo

   Private mName As String
   Private mImportAlias As String

   Public Property ImportAlias() As String
      Get
         Return mImportAlias
      End Get
      Set(ByVal value As String)
         mImportAlias = value
      End Set
   End Property

   Public Property Name() As String
      Get
         Return mName
      End Get
      Set(ByVal value As String)
         mName = value
      End Set
   End Property

End Class

Public Class ImportInfoCollection
   Inherits List(Of ImportInfo)

   Public Sub New()
      ' We always include System
      Me.Add(New ImportInfo With {.Name = "System"})
   End Sub

   Public Overloads Function Add(ByVal import As String) As ImportInfo
      Dim newInfo As New ImportInfo() With {.Name = import}
      Me.Add(newInfo)
      Return newInfo
   End Function

   Protected Overridable Sub AddMinimalImports()
      Me.AddSystemCollectionsGeneric()
      Me.AddSystemLinq()
   End Sub

   Protected Overridable Sub AddGroupImports()
      AddMinimalImports()
   End Sub

   Protected Overridable Sub AddstandardImports()
      AddMinimalImports()
   End Sub

   Public Function AddSystemCollectionsGeneric() As ImportInfo
      Return Me.Add("System.Collections.Generic")
   End Function

   Public Function AddSystemCollections() As ImportInfo
      Return Me.Add("System.Collections")
   End Function

   Public Function AddSystemLinq() As ImportInfo
      Return Me.Add("System.Linq")
   End Function

   Public Function AddSystemXmlLinq() As ImportInfo
      Return Me.Add("System.Xml.Linq")
   End Function

   Public Function AddSystemCollectionsObjectModel() As ImportInfo
      Return Me.Add("System.Collections.ObjectModel")
   End Function

   Public Function AddSystemDataCommon() As ImportInfo
      Return Me.Add("System.Data.Common")
   End Function

   Public Function AddSystemData() As ImportInfo
      Return Me.Add("System.Data")
   End Function

   Public Function AddSystemDataLinq() As ImportInfo
      Return Me.Add("System.Data.Linq")
   End Function

   Public Function AddSystemTransactions() As ImportInfo
      Return Me.Add("System.Transactions")
   End Function

   Public Function AddSystemXml() As ImportInfo
      Return Me.Add("System.Xml")
   End Function

   Public Function AddSystemConfiguration() As ImportInfo
      Return Me.Add("System.Configuration")
   End Function

   Public Function AddSystemDiagnostics() As ImportInfo
      Return Me.Add("System.Diagnostics")
   End Function

   'SystemCore()
   'SystemCollections()

End Class

Public Module ImportInfoExtensions
   <System.Runtime.CompilerServices.Extension()> _
   Public Function Output(ByVal fileImports As ImportInfoCollection) As String
      Dim ret = String.Empty
      For Each importInfo In fileImports
         ret &= importInfo.Output
      Next
      Return ret
   End Function

   <System.Runtime.CompilerServices.Extension()> _
   Public Function Output(ByVal importInfo As ImportInfo) As String
      If String.IsNullOrEmpty(importInfo.ImportAlias) Then
         Return String.Concat(New String() {Strings.importsString, importInfo.Name, Strings.semiColonString, Strings.nl})
      Else
         Return String.Concat(New String() {Strings.importsString, importInfo.ImportAlias & " = ", importInfo.Name, Strings.semiColonString, Strings.nl})
      End If
   End Function
End Module
